package it.fantacalcio.hibernate.dao;

import it.fantacalcio.model.Categoria;

import java.util.List;

import org.hibernate.Query;

public class CategoriaDAOImpl extends BaseHibernateDAO implements CategoriaDAO {


	@Override
	public void save(Categoria categoria) throws Exception {
		getSession().save(categoria);
	}
	
	@Override
	public void delete(Categoria categoria) throws Exception {
		getSession().delete(categoria);
	}

	@Override
	public Categoria get(Long id) throws Exception {
		return (Categoria) getSession().get(Categoria.class, id);
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Categoria> list() throws Exception {
		String queryString = "from Categoria";
		Query queryObject = getSession().createQuery(queryString);
		return queryObject.list();
	}

}
